package com.logicwin.aibala.detailPackActivity;

import com.logicwin.aibala.R;
import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.ScrollView;

public class DetailDesc extends ActivityGroup{
	private ScrollView container = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    // 隐藏标题栏
	    requestWindowFeature(Window.FEATURE_NO_TITLE);
	    // 设置视图
	    setContentView(R.layout.package_detail);
	
	    container = (ScrollView) findViewById(R.id.containerBody);
	    initBtns();		
	}
	
	private void initBtns(){
	    
	    ImageButton btnDesc = (ImageButton) findViewById(R.id.button_description);	    
	    btnDesc.setOnClickListener(new OnClickListener() {
	        @Override
	        public void onClick(View v) {
	        	startFirstPage();
	        }  
	    });	
	    
	    ImageButton btnComments = (ImageButton) findViewById(R.id.button_comments);
	    btnComments.setOnClickListener(new OnClickListener() {
	        @Override
	        public void onClick(View v) {
	        	startSecondPage();
	        }
	    });	
	    
	    ImageButton btnRecommend = (ImageButton) findViewById(R.id.button_recommend);
	    btnRecommend.setOnClickListener(new OnClickListener() {
	        @Override
	        public void onClick(View v) {
	    	startThirdPage();
	        }
	    });
	    
	    ImageButton btnWhoinuse = (ImageButton) findViewById(R.id.button_whoinuse);
	    btnWhoinuse.setOnClickListener(new OnClickListener() {
	        @Override
	        public void onClick(View v) {
	    	startForthPage();
	        }
	    });	    
	}
	private void startFirstPage(){
        container.removeAllViews();
        container.addView(getLocalActivityManager().startActivity(
                "detail_description",
                new Intent(DetailDesc.this, DetailFirstPage.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .getDecorView());		
	}
	private void startSecondPage(){
        container.removeAllViews();
        container.addView(getLocalActivityManager().startActivity(
                "detail_comments",
                new Intent(DetailDesc.this, DetailSecondPage.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .getDecorView());			
	}
	private void startThirdPage(){
        container.removeAllViews();
        container.addView(getLocalActivityManager().startActivity(
                "detail_recommend",
                new Intent(DetailDesc.this, DetailThirdPage.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .getDecorView());			
	}	
	
	private void startForthPage(){
        container.removeAllViews();
        container.addView(getLocalActivityManager().startActivity(
                "detail_whoinuse",
                new Intent(DetailDesc.this, DetailForthPage.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .getDecorView());		
	}
}
